<!DOCTYPE html>
<html class="Content">
<head>
    <title>xUnit.js: Asynchronous Tests</title>
    <link type="text/css" rel="Stylesheet" href="../../Style/documentation.css" />
</head>
<body>
    <h1>Asynchronous Tests</h1>
    <p>
        Some engine hosts (nodejs, phantomjs) provide asynchronous functionality, for performing tasks such as loading files or making web requests. While these types of boundary-crossing 
        events are not appropriate for proper unit tests, they can be useful for targeted integration and smoke tests.
    </p>
    <p>
        To indicate that a test requires asynchronous functionality, use the <strong>Async</strong> attribute. This is equivalent to specifying <em>Fact</em><strong>.Asynchronous=true;</strong> e.g.:
        <span class="Code">
<strong>[Async]</strong>
function SetsPageTitle(callback){
    // Arrange
    var expected="My Page Title";
    var target="http://my.test.site/";

    // Act
    page.load(target, function(pageObject){
        callback(function(){
            var actual=pageObject.title;
        
            // Assert
            Assert.Equal(expected, actual);
        });
    })
}
        </span>
    </p>
    <p>For more information, see the <a href="../Engine/asynchronous-tests.html">Asynchronous Tests</a> page in the Engine section.</p>
</body>
</html>